package org.ws.task.event.support;

import org.ws.task.event.AsyncEventBusHolder;
import org.ws.task.event.EventBusHolder;
import org.ws.task.event.EventListener;
import org.ws.task.event.PushItemEvent;

/**
 * Leader端接收到数据后，发送消息触发分发推送
 */
public class PushItemEventHolder implements EventBusHolder<PushItemEvent> {

    private static final PushItemEventHolder instance = new PushItemEventHolder();

    private final AsyncEventBusHolder<PushItemEvent> eventBusHolder;

    public static PushItemEventHolder getInstance() {
        return instance;
    }

    private PushItemEventHolder(){
        this.eventBusHolder = new AsyncEventBusHolder("PushItemEventBus");
    }

    @Override
    public void registerListener(EventListener<PushItemEvent> listener) {
        this.eventBusHolder.registerListener(listener);
    }

    @Override
    public void publishEvent(PushItemEvent event) {
        this.eventBusHolder.publishEvent(event);
    }
}
